﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;
public partial class zoushitu_dlt_dlt_201yl : System.Web.UI.Page
{
    protected List<Model.LotteryAnnouncement> arlist = null;
    protected string[] SSQList = null;
    protected string SSQblue = null;
    protected DataTable dtPaperList = new DataTable();
    protected int jinqiCount = 0;

    protected Hashtable qqy2_dt = new Hashtable();//前区除3余2
    protected Hashtable qqy0_dt = new Hashtable();//前区除3余0
    protected Hashtable qqy1_dt = new Hashtable();//前区除3余1

    protected Hashtable hqy2_dt = new Hashtable();//后区除3余2
    protected Hashtable hqy0_dt = new Hashtable();//后区除3余0
    protected Hashtable hqy1_dt = new Hashtable();//后区除3余1

    protected Hashtable qqy2_tiao = new Hashtable();
    protected Hashtable qqy0_tiao = new Hashtable();
    protected Hashtable qqy1_tiao = new Hashtable();
    protected Hashtable hqy2_tiao = new Hashtable();
    protected Hashtable hqy0_tiao = new Hashtable();
    protected Hashtable hqy1_tiao = new Hashtable();
    protected int TiaoXing;
    protected void Page_Load(object sender, EventArgs e)
    {
        ZoushiManage.FangWenZouShi();
        if (!IsPostBack)
        {
            jinqiCount = 30;
            bindData(30);
            YiLouZhi1(int.Parse(DropDownList1.SelectedValue));
        }
    }
    protected void bindData(int maxValue)
    {
        arlist = BLL.LotteryAnnouncement.getDatas(maxValue, 2);
        if (arlist != null)
        {
            #region 列表初始化   
            qqy2_dt.Add(0, 02);
            qqy2_dt.Add(1, 05);
            qqy2_dt.Add(2, 08);
            qqy2_dt.Add(3, 12);
            qqy2_dt.Add(4, 15);
            qqy2_dt.Add(5, 18);
            qqy2_dt.Add(6, 22);
            qqy2_dt.Add(7, 25);
            qqy2_dt.Add(8, 28);
            qqy2_dt.Add(9, 32);
            qqy2_dt.Add(10, 35);
            //qqy2_dt.Add(10, 35);
            //qqy2_dt.Add(9, 32);
            //qqy2_dt.Add(8, 28);
            //qqy2_dt.Add(7, 25);
            //qqy2_dt.Add(6, 22);
            //qqy2_dt.Add(5, 18);
            //qqy2_dt.Add(4, 15);
            //qqy2_dt.Add(3, 12);
            //qqy2_dt.Add(2, 08);
            //qqy2_dt.Add(1, 05);
            //qqy2_dt.Add(0, 02);

            qqy0_dt.Add(11, 03);
            qqy0_dt.Add(12, 06);
            qqy0_dt.Add(13, 09);
            qqy0_dt.Add(14, 10);
            qqy0_dt.Add(15, 13);
            qqy0_dt.Add(16, 16);
            qqy0_dt.Add(17, 19);
            qqy0_dt.Add(18, 20);
            qqy0_dt.Add(19, 23);
            qqy0_dt.Add(20, 26);
            qqy0_dt.Add(21, 29);
            qqy0_dt.Add(22, 30);
            qqy0_dt.Add(23, 33);

            //qqy0_dt.Add(23, 33);
            //qqy0_dt.Add(22, 30);
            //qqy0_dt.Add(21, 29);
            //qqy0_dt.Add(20, 26);
            //qqy0_dt.Add(19, 23);
            //qqy0_dt.Add(18, 20);
            //qqy0_dt.Add(17, 19);
            //qqy0_dt.Add(16, 16);
            //qqy0_dt.Add(15, 13);
            //qqy0_dt.Add(14, 10);
            //qqy0_dt.Add(13, 09);
            //qqy0_dt.Add(12, 06);
            //qqy0_dt.Add(11, 03);

            qqy1_dt.Add(24, 01);
            qqy1_dt.Add(25, 04);
            qqy1_dt.Add(26, 07);
            qqy1_dt.Add(27, 11);
            qqy1_dt.Add(28, 14);
            qqy1_dt.Add(29, 17);
            qqy1_dt.Add(30, 21);
            qqy1_dt.Add(31, 24);
            qqy1_dt.Add(32, 27);
            qqy1_dt.Add(33, 31);
            qqy1_dt.Add(34, 34);

            //qqy1_dt.Add(34, 34);
            //qqy1_dt.Add(33, 31);
            //qqy1_dt.Add(32, 27);
            //qqy1_dt.Add(31, 24);
            //qqy1_dt.Add(30, 21);
            //qqy1_dt.Add(29, 17);
            //qqy1_dt.Add(28, 14);
            //qqy1_dt.Add(27, 11);
            //qqy1_dt.Add(26, 07);
            //qqy1_dt.Add(25, 04);
            //qqy1_dt.Add(24, 01);

            hqy2_dt.Add(35, 02);
            hqy2_dt.Add(36, 05);
            hqy2_dt.Add(37, 08);
            hqy2_dt.Add(38, 12);
            //hqy2_dt.Add(38, 12);
            //hqy2_dt.Add(37, 08);
            //hqy2_dt.Add(36, 05);
            //hqy2_dt.Add(35, 02);
            hqy0_dt.Add(39, 03);
            hqy0_dt.Add(40, 06);
            hqy0_dt.Add(41, 09);
            hqy0_dt.Add(42, 10);
            //hqy0_dt.Add(42, 10);
            //hqy0_dt.Add(41, 09);
            //hqy0_dt.Add(40, 06);
            //hqy0_dt.Add(39, 03);
            hqy1_dt.Add(43, 01);
            hqy1_dt.Add(44, 04);
            hqy1_dt.Add(45, 07);
            hqy1_dt.Add(46, 11);
            //hqy1_dt.Add(46, 11);
            //hqy1_dt.Add(45, 07);
            //hqy1_dt.Add(44, 04);
            //hqy1_dt.Add(43, 01);

            #endregion

            for (int i = 0; i < arlist.Count; i++)
            {
                //重号
                string[] redBall = arlist[i].LotteryNo.Split('+')[0].Split(',');
                for (int m = 0; m < redBall.Length; m++)
                {
                    //计算条形图中每个数的个数红球
                    bindTiaoxing(0, int.Parse(redBall[m]));

                }

                string[] blueBall = arlist[i].LotteryNo.Split('+')[1].Split(',');
                for (int m = 0; m < blueBall.Length; m++)
                {
                    //计算条形图中每个数的个数红球
                    bindTiaoxing(1, int.Parse(blueBall[m]));

                }
            }
            #region
            foreach (DictionaryEntry de in qqy2_dt)
            {
                int a = int.Parse(de.Value.ToString()) - 1;
                string b = TiaoxingDT[a].ToString();
                qqy2_tiao.Add(de.Key, b);
            }
            foreach (DictionaryEntry de in qqy0_dt)
            {
                int a = int.Parse(de.Value.ToString()) - 1;
                string b = TiaoxingDT[a].ToString();
                qqy0_tiao.Add(de.Key, b);
            }
            foreach (DictionaryEntry de in qqy1_dt)
            {
                int a = int.Parse(de.Value.ToString()) - 1;
                string b = TiaoxingDT[a].ToString();
                qqy1_tiao.Add(de.Key, b);
            }
            foreach (DictionaryEntry de in hqy2_dt)
            {
                int a = int.Parse(de.Value.ToString()) + 34;
                string b = TiaoxingDT[a].ToString();
                hqy2_tiao.Add(de.Key, b);
            }
            foreach (DictionaryEntry de in hqy0_dt)
            {
                int a = int.Parse(de.Value.ToString()) + 34;
                string b = TiaoxingDT[a].ToString();
                hqy0_tiao.Add(de.Key, b);
            }
            foreach (DictionaryEntry de in hqy1_dt)
            {
                int a = int.Parse(de.Value.ToString()) + 34;
                string b = TiaoxingDT[a].ToString();
                hqy1_tiao.Add(de.Key, b);
            }
            #endregion
        }



    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        jinqiCount = int.Parse(DropDownList1.SelectedValue);
        bindData(int.Parse(DropDownList1.SelectedValue));
        YiLouZhi1(int.Parse(DropDownList1.SelectedValue));
    }
    protected int[] TiaoxingDT = new int[47];
    protected void bindTiaoxing(int type, int data)
    {
        for (int i = 0; i < 47; i++)
        {
            if (type == 0)
            {
                if (data == (i + 1))
                {
                    TiaoxingDT[i] += 1;
                }
            }
            if (type == 1)
            {
                if (data == (i + 1 - 35))
                {
                    TiaoxingDT[i] += 1;
                }
            }
        }
    }

    #region 遗漏用到的变量   
    //protected List<List<List<string>>> Ylist = new List<List<List<string>>>();
    protected List<List<List<string>>> ylist_qqy2 = new List<List<List<string>>>();
    protected List<List<List<string>>> ylist_qqy0 = new List<List<List<string>>>();
    protected List<List<List<string>>> ylist_qqy1 = new List<List<List<string>>>();
    protected List<List<List<string>>> ylist_hqy2 = new List<List<List<string>>>();
    protected List<List<List<string>>> ylist_hqy0 = new List<List<List<string>>>();
    protected List<List<List<string>>> ylist_hqy1 = new List<List<List<string>>>();
    #endregion
    public void YiLouZhi1(int maxValue)
    {
        arlist = BLL.LotteryAnnouncement.getDatas(maxValue, 2);
        if (arlist == null || arlist.Count < 0) return;
        List<List<string>> winList = new List<List<string>>();//记录中奖号码和中奖期数，前区红球
        List<List<string>> blue_winList = new List<List<string>>();//后区篮球
        for (int i = 0; i < arlist.Count; i++)
        {

            string lotteryQS = arlist[i].LotteryQS;//开奖期数
            string lotteryNo = arlist[i].LotteryNo;//开奖号码
            string num = "";
            List<List<string>> y_qqy2 = new List<List<string>>();
            for (int j = 0; j < qqy2_dt.Count; j++)
            {
                #region 前区除3余2
                string[] ball = lotteryNo.Split(new char[] { '+' });
                string redballstr = ball[0];//预测号码中的红球
                string[] redballparm = redballstr.Split(new char[] { ',' });//红球
                if (j < 3)
                {
                    num = "0" + qqy2_dt[j].ToString();
                }
                else
                {
                    num = qqy2_dt[j].ToString();
                }
                string NewQS = "";

                if (i == 0)
                {
                    NewQS = arlist[0].LotteryQS;//当前最新一期
                }
                else
                {
                    for (int m = 0; m < winList.Count; m++)//有命中号码后，将最新一期设为命中的那期
                    {
                        if ((winList[m][1].Contains(num)))
                        {
                            NewQS = winList[m][0];
                        }
                    }
                    if (NewQS == "")
                    {
                        NewQS = arlist[0].LotteryQS;
                    }
                }
                if (((IList)redballparm).Contains(num))
                {
                    #region 命中值
                    List<string> list = new List<string>();
                    list.Add(lotteryQS);
                    list.Add(num);
                    list.Add("0");
                    y_qqy2.Add(list);
                    List<string> list1 = new List<string>();
                    list1.Add(lotteryQS);
                    list1.Add(num);
                    list1.Add(num);
                    winList.Add(list1);
                    #endregion
                }
                else
                {
                    #region 遗漏值
                    int MissingQS = 0;
                    List<string> list = new List<string>();
                    for (int m = 0; m < winList.Count; m++)//有命中号码后，将最新一期设为命中的那期
                    {
                        if ((winList[m][1].Contains(num)))
                        {
                            NewQS = winList[m][0];
                        }
                    }
                    if (NewQS == arlist[0].LotteryQS)
                    {
                        MissingQS = (Convert.ToInt32(lotteryQS) - Convert.ToInt32(NewQS)) + 1;//遗漏期数
                    }
                    else
                    {
                        MissingQS = Convert.ToInt32(lotteryQS) - Convert.ToInt32(NewQS);//遗漏期数
                    }

                    list.Add(lotteryQS);
                    list.Add(qqy2_dt[j].ToString());
                    list.Add(MissingQS.ToString());
                    y_qqy2.Add(list);
                    #endregion
                }
                #endregion
            }
            ylist_qqy2.Add(y_qqy2);


            List<List<string>> y_qqy0 = new List<List<string>>();
            for (int k = 11; k < qqy0_dt.Count + 11; k++)
            {
                #region 前区除3余0
                string[] ball = lotteryNo.Split(new char[] { '+' });
                string redballstr = ball[0];//预测号码中的红球
                string[] redballparm = redballstr.Split(new char[] { ',' });//红球
                if (k < 14)
                {
                    num = "0" + qqy0_dt[k].ToString();
                }
                else
                {
                    num = qqy0_dt[k].ToString();
                }
                string NewQS = "";

                if (i == 0)
                {
                    NewQS = arlist[0].LotteryQS;//当前最新一期
                }
                else
                {
                    for (int m = 0; m < winList.Count; m++)//有命中号码后，将最新一期设为命中的那期
                    {
                        if ((winList[m][1].Contains(num)))
                        {
                            NewQS = winList[m][0];
                        }
                    }
                    if (NewQS == "")
                    {
                        NewQS = arlist[0].LotteryQS;
                    }
                }
                if (((IList)redballparm).Contains(num))
                {
                    #region 命中值
                    List<string> list = new List<string>();
                    list.Add(lotteryQS);
                    list.Add(num);
                    list.Add("0");
                    y_qqy0.Add(list);
                    List<string> list1 = new List<string>();
                    list1.Add(lotteryQS);
                    list1.Add(num);
                    list1.Add(qqy0_dt[k].ToString());
                    winList.Add(list1);
                    #endregion
                }
                else
                {
                    #region 遗漏值
                    int MissingQS = 0;
                    List<string> list = new List<string>();

                    if (NewQS == arlist[0].LotteryQS)
                    {
                        MissingQS = (Convert.ToInt32(lotteryQS) - Convert.ToInt32(NewQS)) + 1;//遗漏期数
                    }
                    else
                    {
                        MissingQS = Convert.ToInt32(lotteryQS) - Convert.ToInt32(NewQS);//遗漏期数
                    }

                    list.Add(lotteryQS);
                    list.Add(num);
                    list.Add(MissingQS.ToString());
                    y_qqy0.Add(list);
                    #endregion
                }
                #endregion
            }
            ylist_qqy0.Add(y_qqy0);


            List<List<string>> y_qqy1 = new List<List<string>>();
            for (int n = 24; n < qqy1_dt.Count + 24; n++)
            {
                #region 前区除3余1
                string[] ball = lotteryNo.Split(new char[] { '+' });
                string redballstr = ball[0];//预测号码中的红球
                string[] redballparm = redballstr.Split(new char[] { ',' });//红球
                if (n < 27)
                {
                    num = "0" + qqy1_dt[n].ToString();
                }
                else
                {
                    num = qqy1_dt[n].ToString();
                }
                string NewQS = "";

                if (i == 0)
                {
                    NewQS = arlist[0].LotteryQS;//当前最新一期
                }
                else
                {
                    for (int m = 0; m < winList.Count; m++)//有命中号码后，将最新一期设为命中的那期
                    {
                        if ((winList[m][1].Contains(num)))
                        {
                            NewQS = winList[m][0];
                        }
                    }
                    if (NewQS == "")
                    {
                        NewQS = arlist[0].LotteryQS;
                    }
                }
                if (((IList)redballparm).Contains(num))
                {
                    #region 命中值
                    List<string> list = new List<string>();
                    list.Add(lotteryQS);
                    list.Add(num);
                    list.Add("0");
                    y_qqy1.Add(list);
                    List<string> list1 = new List<string>();
                    list1.Add(lotteryQS);
                    list1.Add(num);
                    list1.Add(qqy1_dt[n].ToString());
                    winList.Add(list1);
                    #endregion
                }
                else
                {
                    #region 遗漏值
                    int MissingQS = 0;
                    List<string> list = new List<string>();

                    if (NewQS == arlist[0].LotteryQS)
                    {
                        MissingQS = (Convert.ToInt32(lotteryQS) - Convert.ToInt32(NewQS)) + 1;//遗漏期数
                    }
                    else
                    {
                        MissingQS = Convert.ToInt32(lotteryQS) - Convert.ToInt32(NewQS);//遗漏期数
                    }

                    list.Add(lotteryQS);
                    list.Add(num);
                    list.Add(MissingQS.ToString());
                    y_qqy1.Add(list);
                    #endregion
                }
                #endregion
            }
            ylist_qqy1.Add(y_qqy1);

            List<List<string>> y_hqy2 = new List<List<string>>();
            for (int a = 35; a < hqy2_dt.Count + 35; a++)
            {
                #region 后区除3余2
                string[] ball = lotteryNo.Split(new char[] { '+' });
                string redballstr = ball[1];//预测号码中的红球
                string[] redballparm = redballstr.Split(new char[] { ',' });//篮球
                if (a < 38)
                {
                    num = "0" + hqy2_dt[a].ToString();
                }
                else
                {
                    num = hqy2_dt[a].ToString();
                }
                string NewQS = "";

                if (i == 0)
                {
                    NewQS = arlist[0].LotteryQS;//当前最新一期
                }
                else
                {
                    for (int m = 0; m < blue_winList.Count; m++)//有命中号码后，将最新一期设为命中的那期
                    {
                        if ((blue_winList[m][1].Contains(num)))
                        {
                            NewQS = blue_winList[m][0];
                        }
                    }
                    if (NewQS == "")
                    {
                        NewQS = arlist[0].LotteryQS;
                    }
                }
                if (((IList)redballparm).Contains(num))
                {
                    #region 命中值
                    List<string> list = new List<string>();
                    list.Add(lotteryQS);
                    list.Add(num);
                    list.Add("0");
                    y_hqy2.Add(list);
                    List<string> list1 = new List<string>();
                    list1.Add(lotteryQS);
                    list1.Add(num);
                    list1.Add(hqy2_dt[a].ToString());
                    blue_winList.Add(list1);
                    #endregion
                }
                else
                {
                    #region 遗漏值
                    int MissingQS = 0;
                    List<string> list = new List<string>();

                    if (NewQS == arlist[0].LotteryQS)
                    {
                        MissingQS = (Convert.ToInt32(lotteryQS) - Convert.ToInt32(NewQS)) + 1;//遗漏期数
                    }
                    else
                    {
                        MissingQS = Convert.ToInt32(lotteryQS) - Convert.ToInt32(NewQS);//遗漏期数
                    }

                    list.Add(lotteryQS);
                    list.Add(num);
                    list.Add(MissingQS.ToString());
                    y_hqy2.Add(list);
                    #endregion
                }
                #endregion
            }
            ylist_hqy2.Add(y_hqy2);

            List<List<string>> y_hqy0 = new List<List<string>>();
            for (int b = 39; b < hqy0_dt.Count + 39; b++)
            {
                #region 后区除3余0
                string[] ball = lotteryNo.Split(new char[] { '+' });
                string redballstr = ball[1];//预测号码中的红球
                string[] redballparm = redballstr.Split(new char[] { ',' });//篮球
                if (b < 42)
                {
                    num = "0" + hqy0_dt[b].ToString();
                }
                else
                {
                    num = hqy0_dt[b].ToString();
                }
                string NewQS = "";

                if (i == 0)
                {
                    NewQS = arlist[0].LotteryQS;//当前最新一期
                }
                else
                {
                    for (int m = 0; m < blue_winList.Count; m++)//有命中号码后，将最新一期设为命中的那期
                    {
                        if ((blue_winList[m][1].Contains(num)))
                        {
                            NewQS = blue_winList[m][0];
                        }
                    }
                    if (NewQS == "")
                    {
                        NewQS = arlist[0].LotteryQS;
                    }
                }
                if (((IList)redballparm).Contains(num))
                {
                    #region 命中值
                    List<string> list = new List<string>();
                    list.Add(lotteryQS);
                    list.Add(num);
                    list.Add("0");
                    y_hqy0.Add(list);
                    List<string> list1 = new List<string>();
                    list1.Add(lotteryQS);
                    list1.Add(num);
                    list1.Add(hqy0_dt[b].ToString());
                    blue_winList.Add(list1);
                    #endregion
                }
                else
                {
                    #region 遗漏值
                    int MissingQS = 0;
                    List<string> list = new List<string>();

                    if (NewQS == arlist[0].LotteryQS)
                    {
                        MissingQS = (Convert.ToInt32(lotteryQS) - Convert.ToInt32(NewQS)) + 1;//遗漏期数
                    }
                    else
                    {
                        MissingQS = Convert.ToInt32(lotteryQS) - Convert.ToInt32(NewQS);//遗漏期数
                    }

                    list.Add(lotteryQS);
                    list.Add(num);
                    list.Add(MissingQS.ToString());
                    y_hqy0.Add(list);
                    #endregion
                }
                #endregion
            }
            ylist_hqy0.Add(y_hqy0);

            List<List<string>> y_hqy1 = new List<List<string>>();
            for (int c = 43; c < hqy1_dt.Count + 43; c++)
            {
                #region 后区除3余0
                string[] ball = lotteryNo.Split(new char[] { '+' });
                string redballstr = ball[1];//预测号码中的红球
                string[] redballparm = redballstr.Split(new char[] { ',' });//篮球
                if (c < 46)
                {
                    num = "0" + hqy1_dt[c].ToString();
                }
                else
                {
                    num = hqy1_dt[c].ToString();
                }
                string NewQS = "";

                if (i == 0)
                {
                    NewQS = arlist[0].LotteryQS;//当前最新一期
                }
                else
                {
                    for (int m = 0; m < blue_winList.Count; m++)//有命中号码后，将最新一期设为命中的那期
                    {
                        if ((blue_winList[m][1].Contains(num)))
                        {
                            NewQS = blue_winList[m][0];
                        }
                    }
                    if (NewQS == "")
                    {
                        NewQS = arlist[0].LotteryQS;
                    }
                }
                if (((IList)redballparm).Contains(num))
                {
                    #region 命中值
                    List<string> list = new List<string>();
                    list.Add(lotteryQS);
                    list.Add(num);
                    list.Add("0");
                    y_hqy1.Add(list);
                    List<string> list1 = new List<string>();
                    list1.Add(lotteryQS);
                    list1.Add(num);
                    list1.Add(hqy1_dt[c].ToString());
                    blue_winList.Add(list1);
                    #endregion
                }
                else
                {
                    #region 遗漏值
                    int MissingQS = 0;
                    List<string> list = new List<string>();

                    if (NewQS == arlist[0].LotteryQS)
                    {
                        MissingQS = (Convert.ToInt32(lotteryQS) - Convert.ToInt32(NewQS)) + 1;//遗漏期数
                    }
                    else
                    {
                        MissingQS = Convert.ToInt32(lotteryQS) - Convert.ToInt32(NewQS);//遗漏期数
                    }

                    list.Add(lotteryQS);
                    list.Add(num);
                    list.Add(MissingQS.ToString());
                    y_hqy1.Add(list);
                    #endregion
                }
                #endregion
            }
            ylist_hqy1.Add(y_hqy1);
        }

    }


}